using Microsoft.EntityFrameworkCore;
using AIoTGateway_UI.Data.Models;

namespace AIoTGateway_UI.Data;

public class IoTDbContext : DbContext
{
    public IoTDbContext(DbContextOptions<IoTDbContext> options) : base(options)
    {
    }

    public DbSet<Workshop> Workshops { get; set; }
    public DbSet<Device> Devices { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Device>()
            .HasOne(d => d.Workshop)
            .WithMany()
            .HasForeignKey(d => d.WorkshopId);
    }
}